<template>
  <div>
    <el-dialog title="角色编辑" :visible.sync="status.isshow">
      <el-form :model="form">
        <el-form-item label="角色名称" label-width="120px">
          <el-input v-model="form.phone" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="角色昵称" label-width="120px">
          <el-input v-model="form.nickname" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="角色密码" label-width="120px">
          <el-input v-model="form.password" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="状态" label-width="120px">
          <el-switch
            v-model="form.status"
            :active-value="1"
            :inactive-value="2"
          ></el-switch>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="status.isshow = false">取 消</el-button>
        <el-button type="primary" @click="updata">修 改</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { reqmenulist, reqmemberinfo, reqmemberedit } from "../../../http/api";
import { successAlert } from "../../../utils/alert";
import { mapGetters, mapActions } from "vuex";

export default {
  components: {},
  props: ["status"],
  data() {
    return {
      isshow: true,
      form: {
      },
    };
  },
  methods: {
    ...mapActions(["changeInfo"]),
    getOne(uid) {
      reqmemberinfo({
        uid: uid,
      }).then((res) => {
        if (res.data.code == 200) {
          this.form = res.data.list;
          this.form.password=''
        }
      });
    },

    updata() {
      reqmemberedit(this.form).then((res) => {
        if (res.data.code == 200) {
          // 1.弹成功
          successAlert(res.data.msg);
          // 3.弹框消失
          this.status.isshow = false;
          // 4.列表需要重新渲染
          this.$emit("init");
        }
      });
    },
    // 9.弹框关闭

  },
  mounted() {
    //获取数据
    reqmenulist({
      istree: true,
    }).then((res) => {
      if (res.data.code == 200) {
        this.data = res.data.list;
      }
    });
  },
  computed: { ...mapGetters(["info"]) },
  watch: {},
};
</script>
<style scoped lang="less">
@import "../../../less/index.less";
</style>
